package com.hwadee.job.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hwadee.job.dao.RecruitMapper;
import com.hwadee.job.entity.Recruit;
import com.hwadee.job.service.RecruitService;
import com.hwadee.job.util.PageInfo;

@Service
public class RecruitServiceImpl implements RecruitService {

	@Autowired
	private RecruitMapper recruitMapper;
	
	@Override
	public int insert(Recruit record) {
		// TODO Auto-generated method stub
		return recruitMapper.insert(record);
	}

	@Override
	public List<Recruit> selectAll() {
		// TODO Auto-generated method stub
		return recruitMapper.selectRectruit();
	}

	@Override
	public List<Recruit> findByName(String rename) {
		// TODO Auto-generated method stub
		return recruitMapper.findByName(rename);
	}

	@Override
	public PageInfo<Recruit> findPage(int pageIndex, int size, String rename) {
		PageInfo<Recruit> pageInfo = new PageInfo<Recruit>();
		int count = recruitMapper.findCount();
		int num = (pageIndex - 1) * size;
		List<Recruit> list = recruitMapper.findPage(num, size, rename);

		
		pageInfo.setPageIndex(pageIndex);
		pageInfo.setList(list);
		pageInfo.setCount(count);
		pageInfo.setPageSize(size);
		pageInfo.setPageNumber((int) Math.ceil((double) count / size));
		return pageInfo;
	}

	@Override
	public PageInfo<Recruit> findPage1(int pageIndex, int size) {
		PageInfo<Recruit> pageInfo = new PageInfo<Recruit>();
		int count = recruitMapper.findCount();
		int num = (pageIndex - 1) * size;
		List<Recruit> list = recruitMapper.findPage1(num, size);

		
		pageInfo.setPageIndex(pageIndex);
		pageInfo.setList(list);
		pageInfo.setCount(count);
		pageInfo.setPageSize(size);
		pageInfo.setPageNumber((int) Math.ceil((double) count / size));
		return pageInfo;
	}

	@Override
	public int deleteByPrimaryKey(Integer reId) {
		// TODO Auto-generated method stub
		return recruitMapper.deleteByPrimaryKey(reId);
	}

	@Override
	public int updateByPrimaryKey(Recruit record) {
		// TODO Auto-generated method stub
		return recruitMapper.updateByPrimaryKey(record);
	}

	@Override
	public Recruit selectByPrimaryKey(Integer reId) {
		// TODO Auto-generated method stub
		return recruitMapper.selectByPrimaryKey(reId);
	}

	@Override
	public List<Recruit>  selectKeyWord(String rename, String reCompanyName, String rePositiontype, String reDate,
			String reWorkingplace, String reMoney) {
		// TODO Auto-generated method stub
		return recruitMapper.selectKeyWord(rename, reCompanyName, rePositiontype, reDate, reWorkingplace, reMoney);
	}

	/**
	 * 分页+模糊查询
	 */
	@Override
	public List<Recruit> selectKeyWord1(Integer pageIndex, Integer size, String rePositiontype, String reEdurequire,
			String reWorkingplace, String reMoney) {
		// TODO Auto-generated method stub
		return recruitMapper.selectKeyWord1(rePositiontype, reEdurequire, reWorkingplace, reMoney, pageIndex, size);
	}

	@Override
	public int reCount(String rePositiontype, String reEdurequire, String reWorkingplace, String reMoney) {
		// TODO Auto-generated method stub
		return recruitMapper.reCount(rePositiontype, reEdurequire, reWorkingplace, reMoney);
	}

	
//	@Override
//	public PageInfo<Recruit> selectKeyWord1(int pageIndex, int size, String rePositiontype, String reEdurequire,
//			String reWorkingplace, String reMoney) {
//		PageInfo<Recruit> pageInfo = new PageInfo<Recruit>();
//		int count = recruitMapper.findCount();
//		int num = (pageIndex - 1) * size;
//		List<Recruit> list = recruitMapper.selectKeyWord1(rePositiontype, reEdurequire, reWorkingplace, reMoney, num, size);
//
//		
//		pageInfo.setPageIndex(pageIndex);
//		pageInfo.setList(list);
//		pageInfo.setCount(count);
//		pageInfo.setPageSize(size);
//		pageInfo.setPageNumber((int) Math.ceil((double) count / size));
//		return pageInfo;
//	}



	

}
